<!DOCTYPE html>
<%@ page contentType="text/html;charset=UTF-8" language="java"%>
<%@ include file="/WEB-INF/views/taglibs.jsp" %>
<html>
<head> <meta http-equiv="X-UA-Compatible" content="IE=Edge">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<div id="toolbar">
<form id="list" action="list">
<div id="search" class="easyui-panel" title="主页内容信息查询" data-options="fit:true,collapsible:true,border:0"> 
  <table class="searchTable">
	<tr>
		<td>语言：</td>
		<td><input type="combo" id="language" name="language"></td>
		<td>标题：</td>
		<td><input type="text" id="title" name="title"></td>
		<td>类型：</td>
		<td><input type="combo" id="type" name="type"></td>
		<td><button id="queryBtn" type="button" class="button">查询</button></td>
		<td><button id="clearBtn" type="button" class="button">清空</button></td>
	</tr>
   </table>
</div>
</form>
<div class="operate">
	<div class="om-panel-header">主页内容信息列表</div>
	<div class="icon">
		<ul>
<shiro:hasPermission name="pageContent:add">  
			<li><a href="javascript:showAdd('toAdd',1000,600);"><span class="menu1"></span>添加</a></li>
</shiro:hasPermission>
<shiro:hasPermission name="pageContent:delete">  
    			<li><a href="javascript:removeRow('id');"><span class="menu11"></span>删除</a></li>
</shiro:hasPermission>  
		</ul>
	</div>
</div>
</div>
<table id="grid" data-options="fit:true,border:false"></table>
</body>
<script type="text/javascript">
$(function() {
	$('#grid').datagrid({   
	    url:'list', 
	    pageSize :10,
		pageList : [10, 20, 30, 40, 50, 100, 200, 300, 400, 500, 1000],
		striped : true,
		//rownumbers : true,
		pagination : true,
		toolbar : '#toolbar',
	    columns : [[
	                 {width : '50', field : 'ck',checkbox:true},
	                 {width : '150',title : '标题',field : 'title'},
	                 {width : '80',title : '类型',field : 'type',formatter:function(v,r){return JSON.parse('${typeMap}')[v]}},
	                 {width : '250',title : '描述',field : 'remark'},
	                 {width : '100',title : '语言',field : 'language',
	                	 formatter:function(v,r){
	                		 var lang =  JSON.parse('${languageCombo}');
	                		 console.log(lang.length);
	                		 for(var i=0;i<lang.length;i++){
	                			 if(v==lang[i].value){
	                				 return lang[i].text;
	                			 }
	                	    }                	 		
	                 	 }
	                 },
	                 {width : '150',title : '创建日期',align : 'center', field : 'createDate',sortable:true , formatter:function(v,r){if(v != ""){return v;}else{return "————"}}},
 					 {width : '100',title : '操作',field : 'id',
	      	                formatter:function(v,r){
	      	                	var html = "";
					        	<shiro:hasPermission name="pageContent:update">  
					        	html += "<a class='osbut' href='#' onclick='openUrl(\"showEdit?id="+r.id+"\",1000,600);'><span class='menu13'></span>编辑</a>";
					        	</shiro:hasPermission>   
	      	                	return html ? html :"没有其他权限";
	        	            }
	 				}
	            ]]
	}); 
	
	//状态
	$('#language').combobox({  
    	data:JSON.parse('${languageCombo}'),
    	editable:false,
    	panelHeight:'auto'
    });
	//状态
	$('#type').combobox({  
    	data:JSON.parse('${typeCombo}'),
    	editable:false,
    	panelHeight:'auto'
    });
	
	function  updateLevel(id,level){
		var selections = $('#grid').datagrid('getSelections');
		if (selections.length == 0) {
			$.messager.alert('提示:','请至少选择一行记录'); 
			return false;
		}
		var type = '操作';
		//当只有2个参数时,为审核
		$.messager.confirm('提示:','你确认要操作吗?',function(e){
			var ids = [];
	  		for(var i=0;i<selections.length;i++){ids.push(selections[i][id]);}
			if(e){
	  		   $.post('updateReceive',{"ids":ids.toString(),"level":level}, function(data) {
	  			 if (data.successCount>0){
	  					$("#grid").datagrid('reload');
	  					refleshTree&&($("#navtree").tree('reload'));
	  					$.messager.show({ 
	  						title:'温馨提示:', 
	  						msg:type+'成功!', 
	  						timeout:1500, 
	  						showType:'slide'
	  					}); 
	  				} else {
	  					if(data.errMsg){
	  						$.messager.alert('提示:',data.errInfoList[0].errorDes,'warning');
	  					}
	  				}
	  			}, 'json');
			}
		}); 
	}
});

</script>
</html>